﻿using Aspose.Words;
using Aspose.Words.Replacing;
using Aspose.Words.Saving;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommTestNFW
{
    public class ReplaceImage : IReplacingCallback
    {
        public string Path { get; set; }
        public  ReplaceImage(string path)
        {
            Path = path; 
        }

        public ReplaceAction Replacing(ReplacingArgs args)
        {
            var node = args.MatchNode;
            var doc = node.Document as Document;
            var builder = new DocumentBuilder(doc);

            builder.MoveTo(node);

            builder.InsertImage(Path);

            return ReplaceAction.Replace;
        }
    }
}
